from django import forms
from .models import CameraEntry, CameraAccessory

class CameraEntryForm(forms.ModelForm):
    class Meta:
        model = CameraEntry
        fields = ['title', 'brand', 'category', 'release_date', 'sensor_type', 'image_resolution', 'content']
        widgets = {
            'title': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入相机名称'}),
            'brand': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入品牌名称'}),
            'category': forms.Select(attrs={'class': 'form-control'}),
            'release_date': forms.DateInput(attrs={'class': 'form-control', 'type': 'date'}),
            'sensor_type': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '如：全画幅CMOS'}),
            'image_resolution': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '如：2420万像素'}),
            'content': forms.Textarea(attrs={'class': 'form-control', 'rows': 10, 'placeholder': '请输入相机详情...'}),
        }
        labels = {
            'title': '相机名称',
            'brand': '品牌',
            'category': '分类',
            'release_date': '发布日期',
            'sensor_type': '传感器类型',
            'image_resolution': '图像分辨率',
            'content': '相机详情',
        }

class CameraAccessoryForm(forms.ModelForm):
    class Meta:
        model = CameraAccessory
        fields = ['title', 'brand', 'category', 'price_range', 'compatible_cameras', 'content']
        widgets = {
            'title': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入配件名称'}),
            'brand': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入品牌名称'}),
            'category': forms.Select(attrs={'class': 'form-control'}),
            'price_range': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '如：1000-2000元'}),
            'compatible_cameras': forms.SelectMultiple(attrs={'class': 'form-control'}),
            'content': forms.Textarea(attrs={'class': 'form-control', 'rows': 10, 'placeholder': '请输入配件详情...'}),
        }
        labels = {
            'title': '配件名称',
            'brand': '品牌',
            'category': '分类',
            'price_range': '价格范围',
            'compatible_cameras': '兼容相机',
            'content': '配件详情',
        }